package kr.hkit.androidcomplete01.ch17;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.view.MotionEvent;
import android.view.View;

public class StateView extends View {
	private Paint paint;
	private int pt_x;
	private int pt_y;

	public StateView(Context context) {
		super(context);
		paint = new Paint(Paint.ANTI_ALIAS_FLAG);
	}

	public void onDraw(Canvas canvas) {
		super.onDraw(canvas);
		paint.setColor(Color.GREEN);
		canvas.drawCircle(pt_x, pt_y, 16, paint);
	}

	public boolean onTouchEvent(MotionEvent event) {
		super.onTouchEvent(event);
		
		if (event.getAction() == MotionEvent.ACTION_DOWN) {
			pt_x = (int) event.getX();
			pt_y = (int) event.getY();
			invalidate();
			return true;
		}
		return false;
	}

	public int getPt_x() {
		return pt_x;
	}

	public void setPt_x(int pt_x) {
		this.pt_x = pt_x;
	}

	public int getPt_y() {
		return pt_y;
	}

	public void setPt_y(int pt_y) {
		this.pt_y = pt_y;
	}

}
